package net.sourceforge.web.easyui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import net.sourceforge.orm.mybatis.Page;

/**
 * 增强版的分页器，带查询参数，过滤参数，排序等等
 * 
 * @author Alex
 *
 * @param <T>
 */
public class PivotPage<T> extends Page<T> {
	private Map<String, Object> criteriaParams = new HashMap<String, Object>();
	private Map<String, String> sortParam = new LinkedHashMap<String, String>();
	private List<FilterRule> filterRule = new ArrayList<FilterRule>();

	public List<FilterRule> getFilterRule() {
		return filterRule;
	}

	public void setFilterRule(List<FilterRule> filterRule) {
		this.filterRule = filterRule;
	}

	public void addFilterRule(FilterRule fr) {
		filterRule.add(fr);
	}

	public PivotPage() {
		super();
	}

	public PivotPage(int pageNo, int pageSize) {
		super(pageNo, pageSize);
	}

	public Map<String, Object> getCriteriaParams() {
		return criteriaParams;
	}

	public void setCriteriaParams(Map<String, Object> criteriaParams) {
		this.criteriaParams = criteriaParams;
	}

	public void addCriteriaParam(String key, Object value) {
		if (value == null)
			return;
		this.criteriaParams.put(key, value);
	}

	public void addSortParam(String key, String value) {
		this.sortParam.put(key, value);
	}

	public Map<String, String> getSortParam() {
		return sortParam;
	}

	public void setSortParam(Map<String, String> sortParam) {
		this.sortParam = sortParam;
	}

	public Object getCriteriaParam(String k) {
		return criteriaParams.get(k);
	}
}
